﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sinacor.Infra.Common;
using Sinacor.Infra.UI.Authorization.Infra.Authorization.Policy;

namespace Sinacor.Infra.UI.Authorization.Policy.Translator
{
    public class PolicyResponseToPolicy :
        BaseTranslator<Entity.Policy, PolicyResponse, List<Entity.Policy>, List<PolicyResponse>>
    {

        public override Entity.Policy Translate(PolicyResponse from)
        {
            if (from == null)
                return null;

            Entity.Policy to = new Sinacor.Infra.UI.Authorization.Policy.Entity.Policy();

            to.PolicyId = from.PolicyId;
            to.PolicyName = from.PolicyName;

            Entity.Enum.PolicyStatus? status;
            Translator.Enum.PolicyStatusTranslator.Translate(from.PolicyStatus, out status);
            to.PolicyStatus = status;

            Entity.Enum.PolicyType? type;
            Translator.Enum.PolicyTypeTranslator.Translate(from.PolicyType, out type);
            to.PolicyType = type;


            return to;
        }
    }
}
